package com.sudo.boot.netty.packet;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.nio.charset.StandardCharsets;

public class NettyMessageServerHandler extends SimpleChannelInboundHandler<MessageProtocol> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MessageProtocol mp) throws Exception {
        System.out.println("服务器收到数据");
        System.out.println("消息长度：" + mp.getLength());
        System.out.println("消息内容："+ new String(mp.getContent(),StandardCharsets.UTF_8));
    }
}
